home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / dune2mm2.zip / DUNE2MM.C next >
C/C++ Source or Header  |  1992-12-12  |  2KB  |  63 lines

  1. /* Dune 2 Money Maxxer v2.0 - by Patch - FLT Cheats / Editors */
  2.  
  3. #include <stdio.h>
  4. #include <string.h>
  5. #include <stdlib.h>
  6.  
  7. void main(int argc, char **argv)
  8. {
  9.   FILE *fp;
  10.   int i, t, start, end, amount, desclen;
  11.   char filename[20], descrip[30], temp[80], found = 0;
  12.  
  13.   printf("%c[2J",27);
  14.   printf("Dune 2 Money Maxxer v2.0 - by Patch\n");
  15.   printf("        FLT Cheats / Editors       \n");
  16.   printf("───────────────────────────────────\n");
  17.   if (argc < 2)
  18.   {
  19.     printf("Usage: DUNE2MM SAVEGAME AMOUNT\n");
  20.     printf("where: SAVEGAME represents the number of the save game you want\n");
  21.     printf("                to max; can be from 0 - whatever, or A for ALL\n");
  22.     printf("       AMOUNT   represents the number of credits you want to\n");
  23.     printf("                have; can be from 0 - 32767; default is 32767\n");
  24.     exit(1);
  25.   }
  26.  
  27.   if ((argv[1][0] == 'a') || (argv[1][0] == 'A'))
  28.   {
  29.     start = 0;
  30.     end = 999;
  31.   }
  32.   else start = end = atoi(argv[1]);
  33.  
  34.   if (argc == 2) amount = 32767;
  35.     else amount = atoi(argv[2]);
  36.  
  37.   for (i = start; i <= end; i++)
  38.   {
  39.     sprintf(filename,"_save%03d.dat",i);
  40.  
  41.     fp = fopen(filename,"r+b");
  42.     if (fp == NULL)
  43.     {
  44.       if (start == end) printf("Could not open save file [%s]!\n",filename);
  45.       exit(1);
  46.     }
  47.     fseek(fp,19,0);
  48.     desclen = fgetc(fp);
  49.     fgets(descrip,desclen,fp);
  50.     printf("Maxxing money for [%s] - %s\n",filename,descrip);
  51.     fseek(fp,350,0);
  52.     fread(temp,1,80,fp);
  53.     for (t = 0; t < 80; t++)
  54.     {
  55.       if (strncmp(temp + t,"PLYR",4) == 0) found = 1;
  56.       if (found == 1) break;
  57.     }
  58.     fseek(fp,350 + t + 26,0);
  59.     fprintf(fp,"%c%c",amount & 0x00ff,((amount & 0xff00) >> 8));
  60.     fclose(fp);
  61.   }
  62. }
  63.